package com.demo.springboot.client;

import com.demo.springboot.server.web.Response;
import com.google.gson.Gson;
import org.springframework.web.client.RestTemplate;

/**
 * @author zhangliangliang
 *
 * 客户端调用方法：
 *      取决于服务端提供的是什么服务：rest(http) 、 web service 、rpc
 *          rest(rpc) : RestTemplate  或者 HttpClient
 */
public class App {
    private static String HOST_URL="http://127.0.0.1:8080/soa/product/";
    public static void main(String[] args) {

        RestTemplate rt = new RestTemplate();
        String body = rt.getForObject(HOST_URL+"/list",String.class);
        System.out.println(body);
        Response response = new Gson().fromJson(body,Response.class);
        System.out.println(response);
        System.out.println(response.getCode());
        System.out.println(response.getMsg());
        System.out.println(response.getData());

    }
}
